package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.base.util.LogUtils
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.KnowledgeModel
import com.powervision.mvvmdemo.ui.repository.ProjectRepository

/**
 * @auth: njb
 * @date: 2021/12/20 9:57
 * @desc: 描述
 */
class ProjectViewModel :BaseViewModel(){
    private val mRepository by lazy { ProjectRepository() }
    public val mProjectLiveData = StateLiveData<List<KnowledgeModel.DataBean?>>()

    fun getProject() {
        launchWithLoading(requestBlock = {
            mRepository.project()
        }, resultCallback = { it ->
            mProjectLiveData.value = it
            it.data?.forEach {
                LogUtils.d("--projectlist--", it?.name.toString())
            }
        })
    }
}